package com.toocms.jinjuhang.ui.mine.certification

import android.os.Bundle
import androidx.databinding.ObservableField
import com.qmuiteam.qmui.arch.QMUIFragmentActivity
import com.toocms.jinjuhang.config.Constants
import com.toocms.jinjuhang.ui.photoview.PhotoViewAty
import com.toocms.tab.base.BaseViewModel
import com.toocms.tab.base.ItemViewModel
import com.toocms.tab.binding.command.BindingAction
import com.toocms.tab.binding.command.BindingCommand
import java.util.ArrayList

class CertificationItemModel(
    viewModel: BaseViewModel<*>,
    val items: List<String>,
    val item: ObservableField<String>
) : ItemViewModel<BaseViewModel<*>>(viewModel) {
    val itemClickBindingCommand = BindingCommand<BindingAction>(BindingAction {
        val bundle = Bundle()
        bundle.putStringArrayList(Constants.BundleKey.KEY_IMAGES, items as ArrayList<String>)
        bundle.putInt(Constants.BundleKey.KEY_POSITION, items.indexOf(item.get()))
        val photoViewAtyBundle = Bundle()
        photoViewAtyBundle.putBundle(QMUIFragmentActivity.QMUI_INTENT_FRAGMENT_ARG, bundle)
        viewModel.startActivity(PhotoViewAty::class.java, photoViewAtyBundle)
    })
}